<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common/header.jsp"%> 
 
<div style="margin:20px 0;"></div>
	
    <form id="insForm"  name="insForm" method="post" >
    	<input type="hidden" id="ins_uuid" name="ins_uuid" value="${appInsInfEntity.ins_uuid}"/>
    	<input type="hidden" id="area_cd" name="area_cd" value="${appInsInfEntity.area_cd}"/>
    	<input type="hidden" id="sup_ins_uuid" name="sup_ins_uuid" value="${appInsInfEntity.sup_ins_uuid}"/>
    	<div class="easyui-tabs" >
			<div title="基本信息" style="padding:10px;">
				<table cellpadding="5" style="width:100%">    		 
		    		<tr>
		    			<td>机构代码:</td>
		    			<td><input class="easyui-textbox" type="text"  id="ins_cd" name="ins_cd" data-options="required:true,validType:['fixedLengthNum[7]']" value="${appInsInfEntity.ins_cd}"></input></td>    	
		    			<td>机构类别:</td>
		    			<td><code:codeSelect id="ins_type" name="ins_type" code_type="ins_type" showSelect="false" selectId="${appInsInfEntity.ins_type}"></code:codeSelect>	</td>  	     			
		    		</tr>
		    		<tr>
		    			<td>机构中文简称:</td>
		    			<td><input class="easyui-textbox" type="text" name="ins_cn_nm_abbr" data-options="required:true,validType:['length[0,80]']" value="${appInsInfEntity.ins_cn_nm_abbr}"></input></td>    	
		    			<td>机构中文名称:</td>
		    			<td><input class="easyui-textbox" type="text" name="ins_cn_nm" data-options="required:true,validType:['length[0,80]']" value="${appInsInfEntity.ins_cn_nm}"></input></td>  	     			
		    		</tr>
		    		<tr>
		    			<td>机构英文简称:</td>
		    			<td><input class="easyui-textbox" type="text" name="ins_en_nm_abbr" data-options="validType:['englishAndLength[0,120]']" value="${appInsInfEntity.ins_en_nm_abbr}"></input></td>    	
		    			<td>机构英文名称:</td>
		    			<td><input class="easyui-textbox" type="text" name="ins_en_nm" data-options="validType:['englishAndLength[0,120]']" value="${appInsInfEntity.ins_en_nm}"></input></td>  	     			
		    		</tr>
		    		<tr>
		    			<td>联系人:</td>
		    			<td><input class="easyui-textbox" type="text" name="contact_person" data-options="required:true,validType:['length[0,6]']" value="${appInsInfEntity.contact_person}"></input></td>    	
		    			<td>手机:</td>
		    			<td><input class="easyui-textbox" type="text" id="phone" name="phone" data-options="required:true,validType:['mobile']" value="${appInsInfEntity.phone}"></input></td>
		    		</tr>
		    		<tr>
		    			<td>传真:</td>
		    			<td><input class="easyui-textbox" type="text" name="fax_no" data-options="validType:['faxno']" value="${appInsInfEntity.fax_no}"></input></td>    	
		    			<td>电子邮件:</td>
		    			<td><input class="easyui-textbox" type="text" name="email" data-options="validType:['email']" value="${appInsInfEntity.email}"></input></td>  	     			
		    		</tr>
		    		<tr>
		    			<td>地区:</td>
		    			<td><input class="easyui-textbox" type="text" readonly="readonly" id="areaname" value="${areaname}" data-options="required:true"/>
		    			<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="selelctArea">选择</a></td>   
		    			<td>邮编:</td>
		    			<td><input class="easyui-textbox" type="text" name="zip_cd" data-options="validType:['zip']" value="${appInsInfEntity.zip_cd}"></input></td> 			   		     			
		    		</tr>
		    		<tr>
		    			<td>通讯地址:</td>
		    			<td><input class="easyui-textbox" type="text" name="addr" data-options="required:true,validType:['length[0,50]']" value="${appInsInfEntity.addr}"></input></td>
		    			<td>上级机构:</td>
		    			<td><input class="easyui-textbox" type="text" readonly="readonly" id="subinsname" value="${subinsname}" data-options="required:true"/>
		    			<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="selelctIns">选择</a></td>    		     			
		    		</tr>
		    		<tr>
		    			<td>机构状态:</td>
		    			<td><code:codeSelect id="ins_st" name="ins_st" code_type="ins_st" showSelect="false" selectId="${appInsInfEntity.ins_st}"></code:codeSelect></td>    		     			
		    		</tr> 		    		 
		    	</table>
			</div>
			<div title="其他信息"  style="padding:10px;">
				<table cellpadding="5" style="width:100%">    		 
		    		<tr>
		    			<td>机构描述:</td>
		    			<td><input class="easyui-textbox" name="descpt" data-options="multiline:true,validType:['length[0,80]']" style="width:400px;height:100px" value="${appInsInfEntity.descpt}"></input></td>    		     			
		    		</tr>		    		
		    		<tr>
		    			<td>商户审核备注:</td>
		    			<td><input class="easyui-textbox" name="audit_desc" data-options="multiline:true,validType:['length[0,150]']" style="width:400px;height:100px" value="${appInsInfEntity.audit_desc}"></input></td>    		     			
		    		</tr>		    		 		    		 
		    	</table>
			</div>			
		</div>    	  	
	    <div style="text-align:center;padding:5px">
	    	<jiepos:buttonDetailTag menuCode="${menuCode}" formId="insForm"></jiepos:buttonDetailTag>
	    </div>
    </form>
<script>
$(document).ready(function() {
	/*选择按钮*/
	$("#selelctArea").click(function(){
		showAreaTree(areaselected);			
	});
	/*确定按钮回调*/
	function areaselected(nodes){		
		if(nodes && nodes.length > 0){
			$("#area_cd").val(nodes[0].ID);
			$("#areaname").textbox("setValue", nodes[0].NAME);		
		}
	}
	
	$("#selelctIns").click(function(){
		showInsTree(insselected, null,null);
	});
	
	/*确定按钮回调*/
	function insselected(nodes){
		if(nodes && nodes.length > 0){			
			$("#sup_ins_uuid").val(nodes[0].ID);
			$("#subinsname").textbox("setValue", nodes[0].NAME);		
		}
	}
});

function saveIns(url){
	if($("#insForm").form("validate")){
		var ins_cd=$("#ins_cd").val();
		var subinsname=$("#subinsname").val();
		var subinscd=subinsname.substr(0,subinsname.indexOf("-"));			
		if(ins_cd==subinscd){
			$.jpmessage.info('机构与上级机构不能重复!');
			return;
		}
		var areaname = $("#areaname").val();
		if(areaname == ''){
			$.jpmessage.info('地区不能为空!');
			return;
		}
		if(subinsname == ''){
			$.jpmessage.info('上级机构不能为空!');
			return;
		}
    	var options ={
	            url:'<c:url value="/insinf/checkInsInf.do"/>',
	            type:'post',
	            success:function(data){
					  if("success"==data){
						  //表单提交的方法、比如ajax提交
						  $("#insForm").attr("action","../insinf/saveInsInf.do?");
					      document.getElementById("insForm").submit();
					  }else if("f1"==data){
						  $.jpmessage.info('机构代码不能重复!');
					  }else if("f2"==data){
						  $.jpmessage.info('手机不能重复!');
					  }else if("f3"==data){
                          $.jpmessage.info('手机必须是会员登录账号!');
                      }
	            }
	         };
		$("#insForm").ajaxSubmit(options);
	}
}
</script>